// ChildView.h : interface of the CChildView class
// Author:	Dani Brunstein, 3/11/2001
//			Computer Graphics
// Send bugs to: danikoz@cs.technion.ac.il
//
/////////////////////////////////////////////////////////////////////////////

#if !defined(AFX_CHILDVIEW_H__A6E03ADB_CBB0_11D5_9FC4_00D0B718E2CD__INCLUDED_)
#define AFX_CHILDVIEW_H__A6E03ADB_CBB0_11D5_9FC4_00D0B718E2CD__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000



/////////////////////////////////////////////////////////////////////////////
// CChildView window

#include "OurModel.h"
#include "Matrix3D.h"

class CChildView : public CWnd
{
// Construction
public:
	CChildView();

// Attributes
public:

private:
	OurModel m_model;
	Matrix3D m_PerspectiveMatrix;
	Matrix3D m_OrthographicMatrix;
	int m_nProjectionPlane;   // the "d" in the projection matrix
	double m_dbAlpha;	// the alpha part of perspective warp
	Matrix3D m_TransformationMatrix;

	/*Matrix3D m_ObjectRotationMatrix;
	Matrix3D m_WorldRotationMatrix;
	Matrix3D m_ScaleMatrix;
	Matrix3D m_TranslateMatrix;*/

	double m_dbMouseSensetivity;
	bool m_bIsObjectSpace;
	bool m_bDrawBoundingBox;
	int m_nWireColor; //wire frame color
	bool m_bViewAxes;
	bool m_bShouldRender;
	bool m_bNormalSwitchDirection;
	

	//pairs of (direction,is_point)
	vector<pair<Matrix3D,bool> > m_LightSources;
	vector<Matrix3D> m_LightSourcesIntensity;

	static const int nMaxProjectionPlane = 100;
	static const int nMinProjectionPlane = 1;

	Matrix3D m_AmbientIntensity;

	int m_nAxis;					// Axis of Action, X Y or Z
	int m_nAction;					// Rotate, Translate, Scale
	int m_nView;					// Orthographics, perspective
	bool m_bIsPerspective;			// is the view perspective
	
	bool m_bBackFaceCulling;		// is Back Face Culling enabled
	bool m_bBackgroundImage;		// is a Background image used
	
	bool m_bNormalPerFace;          // normal per face on/off 
	bool m_bNormalPerVertex;		// normal per vertex on/off
	bool m_bNormalReverse;			// normal reverse
	int m_iBkgColor;                // the normal color in COLORREF format
	//CString m_strBmpFileName;		// file name to use as background

	CString m_strDataFileName;		// file name 
	
	CString m_strSaveRenderToFileName;	// file name to save image as bmp
	int m_nRenderToFile_Height;			// height of bmp output image
	int m_nRenderToFile_Width;			// width of bmp output image

	int m_nLightShading;			// shading: Flat, Gouraud, Phong.

	double m_lMaterialAmbient;		// The Ambient in the scene
	double m_lMaterialDiffuse;		// The Diffuse in the scene
	double m_lMaterialSpecular;		// The Specular in the scene
	int m_nMaterialCosineFactor;	// The cosine factor for the specular

	int m_nArrLightDirection[3];	// holds the light direction

	int m_nXCoord;					// hold last mouse x coord
	int m_nYCoord;					// hold last mouse y coord
	
	bool m_viewOctTree;            // a flag for viewing octtree - ex3
public:


	
// Overrides
	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CChildView)
	protected:
	virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
	//}}AFX_VIRTUAL

// Implementation
public:
	virtual ~CChildView();

	// Generated message map functions
protected:
	//{{AFX_MSG(CChildView)
	afx_msg void OnPaint();
	afx_msg void OnFileLoad();
	afx_msg void OnAxisX();
	afx_msg void OnUpdateAxisX(CCmdUI* pCmdUI);
	afx_msg void OnAxisY();
	afx_msg void OnUpdateAxisY(CCmdUI* pCmdUI);
	afx_msg void OnAxisZ();
	afx_msg void OnUpdateAxisZ(CCmdUI* pCmdUI);
	afx_msg void OnMouseMove(UINT nFlags, CPoint point);
	afx_msg void OnActionRotate();
	afx_msg void OnUpdateActionRotate(CCmdUI* pCmdUI);
	afx_msg void OnActionScale();
	afx_msg void OnUpdateActionScale(CCmdUI* pCmdUI);
	afx_msg void OnActionTranslate();
	afx_msg void OnUpdateActionTranslate(CCmdUI* pCmdUI);
	afx_msg void OnViewOrthographic();
	afx_msg void OnUpdateViewOrthographic(CCmdUI* pCmdUI);
	afx_msg void OnViewPerspective();
	afx_msg void OnUpdateViewPerspective(CCmdUI* pCmdUI);
	afx_msg void OnOptionsBackfaceculling();
	afx_msg void OnUpdateOptionsBackfaceculling(CCmdUI* pCmdUI);
	afx_msg void OnOptionsBackground();
	afx_msg void OnUpdateOptionsBackground(CCmdUI* pCmdUI);
	afx_msg void OnRenderGo();
	afx_msg void OnRenderSave();
	afx_msg void OnLightShadingFlat();
	afx_msg void OnUpdateLightShadingFlat(CCmdUI* pCmdUI);
	afx_msg void OnLightShadingGuoraud();
	afx_msg void OnUpdateLightShadingGuoraud(CCmdUI* pCmdUI);
	afx_msg void OnLightShadingPhong();
	afx_msg void OnUpdateLightShadingPhong(CCmdUI* pCmdUI);
	afx_msg void OnLightShadingGouraud();
	afx_msg void OnUpdateLightShadingGouraud(CCmdUI* pCmdUI);
	afx_msg void OnLightConstants();
	afx_msg void OnLightDirections();
	afx_msg void OnUpdateViewNormalsSwitched(CCmdUI* pCmdUI);
	//}}AFX_MSG
	afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
	afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
	

	void rotate(int nValue);
	void translate(int nXValue, int nYValue);
	void scale(int nValue);
	DECLARE_MESSAGE_MAP()

	
public:
	afx_msg void OnNormalsVertices();
	afx_msg void OnUpdateNormalsVertices(CCmdUI *pCmdUI);
	afx_msg void OnNormalsFaces();
	afx_msg void OnUpdateNormalsFaces(CCmdUI *pCmdUI);
	afx_msg void OnNormalsReverse();
	afx_msg void OnUpdateNormalsReverse(CCmdUI *pCmdUI);
	afx_msg BOOL OnEraseBkgnd(CDC* pDC);
	afx_msg void OnAddcurveQuadratic();
	afx_msg void OnAddcurveCubic();
	afx_msg void OnAnimationEditcurve();
	afx_msg void OnAnimationRemovecurve();
	afx_msg void OnViewOcttree();
	afx_msg void OnUpdateViewOcttree(CCmdUI *pCmdUI);
	afx_msg void OnTimer(UINT nIDEvent);
	afx_msg void OnAnimationStart();
	afx_msg void OnAnimationEnd();
	
	afx_msg void OnReset();
	afx_msg void OnActionReset();
	
	afx_msg void OnViewBoundingbox();
	afx_msg void OnUpdateViewBoundingbox(CCmdUI* pCmdUI);
	afx_msg void OnUpdateSpaceObject(CCmdUI* pCmdUI);
	afx_msg void OnUpdateSpaceWorld(CCmdUI* pCmdUI);
	afx_msg void OnUpdateViewAxes(CCmdUI* pCmdUI);
	afx_msg void OnOptionsSetmousesensetivity();
	
public:
	afx_msg void OnOptionsW();
public:
	afx_msg void OnSpaceWorld();
public:
	afx_msg void OnSpaceObject();
public:
	afx_msg void OnViewAxis();
	afx_msg void OnOptionsSetprojectionplain();
	afx_msg void OnLightconstants();
	afx_msg void OnLightsources();
public:
	afx_msg void OnNormalsSwitchdirection();
public:
	afx_msg void OnShadingFlat();
public:
	afx_msg void OnUpdateShadingFlat(CCmdUI *pCmdUI);
public:
	afx_msg void OnShadingGouraud();
public:
	afx_msg void OnUpdateShadingGouraud(CCmdUI *pCmdUI);
public:
	afx_msg void OnShadingPhong();
public:
	afx_msg void OnUpdateShadingPhong(CCmdUI *pCmdUI);
};

/////////////////////////////////////////////////////////////////////////////

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_CHILDVIEW_H__A6E03ADB_CBB0_11D5_9FC4_00D0B718E2CD__INCLUDED_)
